<%= hidden_field_tag(:wf_id, wf_filter.id) %>
<%= hidden_field_tag(:wf_type, wf_filter.class.name) %>
<%= hidden_field_tag(:wf_dirty, "false") %>
<%= hidden_field_tag(:wf_submitted, "false") %>
<%= hidden_field_tag(:wf_name, wf_filter.name) %>

<% unless WillFilter::Config.require_filter_extensions? %>
  <%= hidden_field_tag(:wf_model, wf_filter.model_class_name) %>
<% end %>

<%= hidden_field_tag(:wf_export_format, "") %>
<%= hidden_field_tag(:wf_export_fields, "") %>

<div class="wf_header">
  <% if wf_filter.show_export_options? %>
    <div class="end" style="padding-left:3px;">
      <button type="button" class="btn btn-default btn-xs" onclick="wfExporter.show(this)">
        Export Data...
      </button>
    </div>
  <% end %>

  <% if wf_filter.show_save_options? %>
    <div class="end">
      <button type="button" class="btn btn-default btn-xs" onclick="wfFilter.saveFilter()">
        Save As New...
      </button>

      <% if wf_filter.id %>
        <button type="button" class="btn btn-default btn-xs" onclick="wfFilter.updateFilter()">
          Update
        </button>
        <button type="button" class="btn btn-default btn-xs" onclick="wfFilter.deleteFilter()">
          Delete
        </button>
      <% end %>
    </div>
  <% end %>

  <div>
    <% unless wf_filter.filter_options.empty? %>
      <%= select_tag(:wf_key, grouped_options_for_select(wf_filter.filter_options, wf_filter.key), {:onChange => "wfFilter.loadSavedFilter()", style: 'width:250px'}) %>
      <script>
        $("#wf_key").select2({
          placeholder: "Select pre-defined or saved filter"
        }).on("change", function (e) {
          wfFilter.loadSavedFilter();
        });
      </script>
  <% end %>
  </div>
</div>
